package com.ruoyi.common.threadlocal;

/**
 * 存放用户姓名的容器
 */
public class UserThreadLocalUtils {

    private final static ThreadLocal<String> userThreadLocal = new ThreadLocal<>();

    /**
     * 获取线程中的用户
     *
     * @return
     */
    public static String getUserName() {
        return userThreadLocal.get();
    }

    /**
     * 设置当前线程中的用户
     *
     * @param userName
     */
    public static void setUserName(String userName) {
        userThreadLocal.set(userName);
    }
    
    /**
     * 移除当前线程的用户
     */
    public static void removeUserName(){userThreadLocal.remove();}

}
